#include <bits/stdc++.h>

#define in read()
#define fi first
#define se second
#define pb push_back
#define y1 y_alpha_1

using namespace std;

using ll = long long;
using db = double;
using vec = vector<int>;
using pii = pair<int,int>;

int read() {
	int x = 0; bool f = 0; char ch = getchar();
	while(!isdigit(ch)) f |= ch == '-',ch = getchar();
	while(isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48),ch = getchar();
	return f ? -x : x;
}

const int N = 1e3 + 10;

struct dot { int l,r; ll w,val1,val2; } pot[N];
bool operator < (dot a,dot b) { return a.r ^ b.r ? a.r < b.r : a.l < b.l; }
ll f[N],ans;
int n;

ll calc(int x,int y) {
	int d = (y - x) & 1;
	return (ll) (y - x + 1 + 1 + d) * (y - x + 1 + 1 - d) / 4;
}

int main() {
#ifndef ONLINE_JUDGE
	freopen("1.in","r",stdin);
#endif
	n = in; for(int i = 1,x,y;i <= n;i++) x = in, y = in, pot[i].l = x + y + 1, pot[i].r = x - y - 1, pot[i].val1 = in, pot[i].w = calc(pot[i].l,pot[i].r);
	for(int i = 1;i <= n;i++) for(int j = 1;j <= n;j++) if(pot[j].l <= pot[i].l && pot[j].r >= pot[i].r) pot[j].val2 += pot[i].val1;
	sort(pot + 1,pot + n + 1);
	for(int i = 1;i <= n;i++) {
		ll cost = 0,v = pot[i].val2 - pot[i].w; int pos = 1; f[i] = v;
		for(int j = 1;j < i;j++)
			if(pot[j].l < pot[i].l && pot[j].r >= pot[i].l) {
				while(pos <= i && pot[pos].r <= pot[j].r) {
					if(pot[pos].l >= pot[i].l) cost += pot[pos].val1;
					pos++;
				}
				f[i] = max(f[i],f[j] + calc(pot[i].l,pot[j].r) - cost + v);
			} else if(pot[j].r < pot[i].l) f[i] = max(f[i],f[j] + v);
		ans = max(ans,f[i]);
	}
	printf("%lld\n",ans);
	return 0;
}
